package com.dianda.controller;

import com.dianda.pojo.User;
import com.dianda.pojo.UserResult;
import com.dianda.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired
    UserService service;

    @PostMapping("/app11/user/login")
    public UserResult getfindById (@RequestBody User user){
        User user1 = service.login(user.getTelephone(),user.getPassword());
            UserResult r = new UserResult();
        if (user1 != null) {
            r.setSuccess(true);
            r.setMsg("成功");
        }else{
            r.setSuccess(false);
            r.setMsg("失败");
        }
        return r;
    }
    @PostMapping("/app12/user/register")
    public UserResult add(@RequestBody User user){
        UserResult r = new UserResult();
        User user1 = service.add(user);
        if(user1!=null){
            r.setSuccess(true);
            r.setMsg("成功");
        }else{
            r.setSuccess(false);
            r.setMsg("失败");
        }
        return r;
    }
}
